clear all
set more off
cd "/homes/nber/yasenov"

use "~/matched_30_40_ready.dta"

********************
*** REGRESSIONS ****
********************
global ind_controls age_A married_A black literate_A c.age_A#c.age_A c.age_A#i.black c.age_A#i.married_A i.black#i.married_A c.age_A#i.literate_A i.literate_A#i.black i.literate_A#i.married
global cnty_controls lnpop30 s_young s_agric s_mf s_urban s_illiterate dustbowl extreme_phdi pop_dens
global more_controls $cnty_controls rldf3329 c.rldf3329#c.rldf3329 miles_to_mex c.miles_to_mex#c.miles_to_mex c.miles_to_mex#c.rldf3329 aa relief loan death_rate rldf3933 c.rldf3933#c.rldf3933

global options cluster(county) absorb(statefip_A)
	 
label var mex_share10 "Mex Share 1910"
label var miles_to_mex "Miles to Mex"
label var rail2 "Railroad"
label var rail_interact "Railroad IV"
label var pctdem "\% Democrats"
label var pctdem_interact "\% Democrats IV"
label var close_to_rr "Close to RR"
label var close_to_rr_interact "Close to RR IV"
	 
***************
***************
***************

eststo clear

eststo: reghdfe dmex mex_share10 $ind_controls $cnty_controls, $options
estadd local bslncntrl "X"
estadd local morecntrls "" 
eststo: reghdfe dmex mex_share10 $ind_controls $more_controls, $options
estadd local bslncntrl "X"
estadd local morecntrls "X" 

eststo: reghdfe dmex rail_interact $ind_controls $cnty_controls rail2, $options
estadd local bslncntrl "X"
estadd local morecntrls "" 
eststo: reghdfe dmex rail_interact $ind_controls $more_controls rail2, $options
estadd local bslncntrl "X"
estadd local morecntrls "X" 

eststo: reghdfe dmex close_to_rr_interact $ind_controls $cnty_controls close_to_rr, $options
estadd local bslncntrl "X"
estadd local morecntrls "" 
eststo: reghdfe dmex close_to_rr_interact $ind_controls $more_controls close_to_rr, $options
estadd local bslncntrl "X"
estadd local morecntrls "X" 

esttab using "~/firststage.tex", ///
	keep(mex_share10 rail_interact close_to_rr_interact) ///
	replace se(3) b(3) ar2 star(* 0.10 ** 0.05 *** 0.01) nonum nonotes noconstant nogaps label ///
	mtitles("(1)" "(2)" "(3)" "(4)" "(5)" "(6)") /// 
	scalars("bslncntrl Baseline Controls" "morecntrls Full Controls") ///
	prehead("{\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}\begin{tabular}{l*{6}{c}}\hline\hline \\ %")
